﻿using Sys.Common;
using Sys.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sys.Core.Sys
{
    /// <summary>
    /// 角色业务
    /// </summary>
    public class RoleBll : ExampleSort<SysRole, RoleBll>
    {
        /// <summary>
        /// 排序实体
        /// </summary>
        public IQueryable<SysRole> SortEntities
        {
            get { return Entities.OrderBy(m => m.IntSort); }
        }

        /// <summary>
        /// 根据用户编号获取列表
        /// </summary>
        /// <param name="id">用户编号</param>
        /// <returns>角色列表</returns>
        public IQueryable<SysRole> EntitiesByUserID(string id)
        {
            var urlist = UserRoleBll.I.EntitiesByUserID(id).ToList();

            string urids = StringHelper.JoinField(urlist, "RoleID");

            return SortEntities.Where(m => urids.Contains(m.ID));
        }
    }
}
